// 全局过滤器
import * as searchOptions from './options'

// eslint-disable-next-line no-unused-vars
const createFilter = (Vue, name) => {
  Vue.filter(`${name}Filter`, value => {
    let ret = ''
    if (value || value === 0) {
      for (const item of searchOptions[name]) {
        if (item.value === value) {
          ret = item.label
          break
        }
      }
    }
    return ret
  })
}

export default (Vue) => {
  Vue.filter('upperCase', value => {
    if (!value) return ''
    value = value.toString()
    return value.toUpperCase()
  })

  Vue.filter('moneyFilter', value => {
    if (!value || isNaN(value)) return value
    return Util.parseMoney(value)
  })

  Vue.filter('timeFilter', value => {
    if (!value) return ''
    return Util.parseTime(value, '{y}-{m}-{d} {h}:{i}:{s}')
  })

  Vue.filter('dateFilter', value => {
    if (!value) return ''
    return Util.parseTime(value, '{y}-{m}-{d}')
  })

  /* 客户来源 */
  // createFilter(Vue, 'handleStatus')
}
